<?xml version='1.0' encoding='UTF-8' ?>
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
	xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
	xmlns:tags="http://tags.com/facelets">
		<h:commandButton id="btnNextPage" style="display: none"
			action="#{mb.list}">		
			<f:ajax execute="divTable" 
					render="divTable #{updateOnChange}" onevent="onPaginationComplete" />
		</h:commandButton>
		<h:inputHidden id="txtCurrentIndex" value="#{mb.paginationResult.currentIndex}"/>
		<h:panelGroup layout="block" styleClass="row clearfix ">
			<h:panelGroup layout="block" styleClass="hidden-xs col-md-6 text-left form-inline " style="padding-top: 10px;">
				<h:outputText value="Página "/>
				<h:panelGroup layout="block" class="form-group">
					<h:inputText id="txtCurrentPage" value="#{mb.paginationResult.currentPage}" style="width:50px;" styleClass="form-control" onchange="changePage();" />
				</h:panelGroup>					
				<h:outputText value=" de #{mb.paginationResult.pageNumbers} dos #{mb.paginationResult.size} registros"/>
			</h:panelGroup>
			<h:panelGroup layout="block" styleClass="col-md-6 text-right " style="padding-top: 13px;">
				<ul class="pagination" style="margin: 0px !important;">

					<c:if test="#{mb.paginationResult.currentIndex eq 0}">
						<li class="disabled"><a href="#">«</a></li>
					</c:if>
					<c:if test="#{mb.paginationResult.currentIndex ne 0}">
						<li><a href="#" onclick="setCurrentIndex(#{mb.paginationResult.currentIndex-1})">«</a></li>
					</c:if>

					<c:forEach var="pageIndex" items="#{mb.paginationResult.pageList}">
						<c:if test="#{mb.paginationResult.currentIndex ne (pageIndex-1)}">
							<li><a href="#" onclick="setCurrentIndex(#{pageIndex-1})">#{pageIndex}</a></li>
						</c:if>
						<c:if test="#{mb.paginationResult.currentIndex eq (pageIndex-1)}">
							<li class="active"><a href="#" onclick="setCurrentIndex(#{pageIndex-1})">#{pageIndex}
									<span class="sr-only">(current)</span>
							</a></li>
						</c:if>
					</c:forEach>

					<c:if test="#{(mb.paginationResult.currentIndex + 1) lt mb.paginationResult.pageNumbers}">
						<li><a href="#" onclick="setCurrentIndex(#{mb.paginationResult.currentIndex+1})" >»</a></li>
					</c:if>
					
					<c:if test="#{(mb.paginationResult.currentIndex + 1) ge mb.paginationResult.pageNumbers}">
						<li class="disabled"><a href="#">»</a></li>
					</c:if>
				</ul>
			</h:panelGroup>
		</h:panelGroup>

</ui:composition>